package com.ibm.workplace.wcm.cqplugin.cq;

import com.ibm.workplace.wcm.cqplugin.*;


public class CqDefectInfo implements IBugInfo {
    
    private String number;
    private String abstractStr;
    private String release;
    private String component;    
    private String owner;
    private String ownerEmailAddress;
    private String originator;
    private String originatorEmailAddress;
    private BugState state;
    private BugPriority priority;
    private BugSeverity severity;
    private String testType;
    
    private String defectlink;//this is passed from CQHttpTest
    
    private IConnectionProfile connectionProfile;
    
    public CqDefectInfo(String number) {
        super();
        
        this.number = number;
    }
    
    public CqDefectInfo(String number, String abstractStr, String release, String component, String owner, String ownerEmailAddress, String originator, String originatorEmailAddress, String stateStr, String priorityStr, String severityStr) {
        super();
        
        this.number = number;
        this.abstractStr = abstractStr;
        this.release = release;
        this.component = component;
        this.owner = owner;
        this.ownerEmailAddress = ownerEmailAddress;
        this.originator = originator;
        this.originatorEmailAddress = originatorEmailAddress;
        
        if (stateStr != null) {
            this.state = BugState.getBugStateFromCode(stateStr);
        }
        
        if (priorityStr != null) {
        	if(Activator.DEBUG_ON)
        		System.out.println("Priority str: " + priorityStr);
            this.priority = BugPriority.getBugPriorityFromCode(priorityStr);
        }
        
        if (severityStr != null) {
        	if(Activator.DEBUG_ON)
        		System.out.println("severityStr str: " + severityStr);
            this.severity = BugSeverity.getBugSeverityFromCode(severityStr);
        }
    }

    public String getDescription() {
        return abstractStr;
    }

    public String getId() {
        return number;
    }

    public String getOriginatorId() {
        return originator;
    }

    public String getOwnerId() {
        return owner;
    }

    public BugPriority getPriority() {
        return priority;
    }

    public BugState getState() {
        return state;
    }
    
    public String getTestType() {
        return testType;
    }    
    
    public void setTestType(String testType) {
        this.testType = testType;
    }
    
    public void setAbstractStr(String abstractStr) {
        this.abstractStr = abstractStr;
    }

    
    public void setNumber(String number) {
        this.number = number;
    }

    
    public void setOriginator(String originator) {
        this.originator = originator;
    }

    
    public void setOwner(String owner) {
        this.owner = owner;
    }

    
    public void setPriority(BugPriority priority) {
        this.priority = priority;
    }

    
    public void setState(BugState state) {
        this.state = state;
    }

    
    public String getOriginatorEmailAddress() {
        return originatorEmailAddress;
    }

    
    public void setOriginatorEmailAddress(String originatorEmailAddress) {
        this.originatorEmailAddress = originatorEmailAddress;
    }

    
    public String getOwnerEmailAddress() {
        return ownerEmailAddress;
    }

    
    public void setOwnerEmailAddress(String ownerEmailAddress) {
        this.ownerEmailAddress = ownerEmailAddress;
    }

    public boolean equals(Object o) {
        boolean ret = false;
        if (o instanceof CqDefectInfo && getId() != null && getId().trim().equalsIgnoreCase(((CqDefectInfo)o).getId())) {
            IConnectionProfile profile1 = getConnectionProfile();
            IConnectionProfile profile2 = ((CqDefectInfo)o).getConnectionProfile();
            if (profile1 == profile2 || (profile1 != null && profile2 != null && profile1.equals(profile2))) {
                ret = true;
            }
        } 
        
        return ret;
    }

    public BugSeverity getSeverity() {
        return severity;
    }

    public IConnectionProfile getConnectionProfile() {
        return connectionProfile;
    }
    
    public void setConnectionProfile(IConnectionProfile connectionProfile) {
        this.connectionProfile = connectionProfile;
    }

    
    public String getComponent() {
        return component;
    }
    
    public void setComponent(String component) {
        this.component = component;
    }
   
    public String getRelease() {
        return release;
    }
    
    public void setRelease(String release) {
        this.release = release;
    }

	public String getOriginator() {
		return originator;
	}

	public String getOwner() {
		return owner;
	}

	public void setSeverity(BugSeverity severity) {
		this.severity = severity;
	}

	public String getDefectlink() {
		return defectlink;
	}

	public void setDefectlink(String defectlink) {
		this.defectlink = defectlink;
	}
    
}
